package com.wjy.sfhcore.ui.fragment.list;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import java.util.ArrayList;
import java.util.List;

public abstract class BaseListAdapter<D> extends ArrayAdapter<D> {
	private List<D> mInfos = new ArrayList<D>();
	protected LayoutInflater mInflater;
	protected Context context;
	public BaseListAdapter(Context context) {
		super(context, android.R.layout.simple_list_item_2);
		mInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.context = context;
	}

	public int getCount() {
		return mInfos.size();
	}

	public D getItem(int position) {
		return mInfos.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public abstract View getView(int position, View convertView,
			ViewGroup parent);

	public void setDatas(List<D> infos) {
		mInfos = infos;
		notifyDataSetChanged();
	}

	public List<D> getDatas() {
		return mInfos;
	}

}
